import request from "@/utils/request";

// 查询客户列表
export function listCustomer(params) {
  return request({
    url: "/customerProfile/list",
    method: "get",
    params: params, // 修改为data，因为通常列表查询使用POST请求体传递参数
  });
}

// 查询客户等级列表
export function listCustomerLevel(query) {
  return request({
    url: "/customer/level/list",
    method: "get",
    data: query, // 修改为data，因为通常列表查询使用POST请求体传递参数
  });
}
// 查询客户详细信息
export function getCustomer(id) {
  return request({
    url: `/customerProfile/detail/${id}`,
    method: "get",
  });
}

// 新增客户
export function addCustomer(data) {
  return request({
    url: "/customerProfile/add",
    method: "post",
    data: data,
  });
}

// 修改客户信息
export function updateCustomer(data) {
  return request({
    url: "/customerProfile/edit",
    method: "put",
    data: data,
  });
}

// 删除客户
export function delCustomer(ids) {
  return request({
    url: "/customerProfile/remove/" + ids,
    method: "delete",
  });
}

// 导出客户列表
export function exportCustomer(query) {
  return request({
    url: "/customerProfile/export",
    method: "post",
    data: query,
    responseType: "blob", // 添加responseType以支持文件下载
  });
}

// 检查客户名称是否唯一
export function checkCustomerNameUnique(name) {
  return request({
    url: "/customerProfile/checkNameUnique",
    method: "get",
    params: { name },
  });
}

// 检查手机号是否唯一
export function checkPhoneUnique(phone) {
  return request({
    url: "/customerProfile/checkPhoneUnique",
    method: "get",
    params: { phone },
  });
}
export function getDeliveryMethodTree() {
  return request({
    url: "/delivery-method/tree",
    method: "get",
  });
}
// 拉黑/解黑客户
export function blockCustomer(customerId, status) {
  return request({
    url: `/customerProfile/block/${customerId}/${status}`,
    method: "post",
  });
}

// 注销客户
export function cancelCustomer(customerId) {
  return request({
    url: `/customerProfile/cancel/${customerId}`,
    method: "post",
  });
}
export function listSalespersonList() {
  return request({
    url: "/customerProfile/salespersonList",
    method: "get",
  });
}

// 获取价格方案下拉列表
export function listPricingPlan() {
  return request({
    url: "/customerProfile/pricingPlanOptions",
    method: "get",
  });
}

// 查询运费模板下拉
export function templateList(query) {
  return request({
    url: "/logisticsTemplate/templateList",
    method: "get",
    params: query,
  });
}
